package day17.homework;

/**
 * 测试类，用于测试Shape抽象类及其子类Rectangle和Circle
 */
public class TestShape {
    public static void main(String[] args) {
        // 创建矩形对象
        Rectangle rectangle = new Rectangle("红色", 5.0, 3.0);
        System.out.println("矩形信息: " + rectangle.toString());
        System.out.println("矩形颜色: " + rectangle.getColor());
        System.out.println("矩形面积: " + rectangle.area());
        System.out.println();
        
        // 创建圆形对象
        Circle circle = new Circle("蓝色", 4.0);
        System.out.println("圆形信息: " + circle.toString());
        System.out.println("圆形颜色: " + circle.getColor());
        System.out.println("圆形面积: " + circle.area());
        System.out.println();
        
        // 使用Shape引用指向子类对象，体现多态性
        Shape shape1 = new Rectangle("绿色", 6.0, 4.0);
        Shape shape2 = new Circle("黄色", 3.0);
        
        System.out.println("通过Shape引用访问矩形:");
        System.out.println("颜色: " + shape1.getColor());
        System.out.println("面积: " + shape1.area());
        System.out.println();
        
        System.out.println("通过Shape引用访问圆形:");
        System.out.println("颜色: " + shape2.getColor());
        System.out.println("面积: " + shape2.area());
    }
}